﻿Imports Mysoft.Map.Data

Public Class IPublic
   

    '''功能:    根据运营门户系统项目GUID获取 ERP下项目GUID
    '''参数:    strDssProjGUID     DSS中项目GUID
    '''         strSysCode         系统编码
    '''         intReturnType      返回值类型 1： 项目GUID ,>1： 项目GUID||项目Code||ProjName
    '''返回值:  String             ERP 下项目GUID     
    '''创建人:  胡智文
    '''创建时间:2011-01-17
    Public Shared Function GetERPProjGUID(ByVal strDssProjGUID As String, ByVal strSysCode As String, Optional ByVal intReturnType As Integer = 1) As String
        If String.IsNullOrEmpty(strDssProjGUID) Then
            Return ""
        End If
        Try
            If intReturnType = 1 Then
                Return MyDB.GetDataItemString(String.Format(" SELECT ProjGUID FROM p_project WHERE MainProjGUID = '{0}' and  ApplySys LIKE '%{1}%' ", strDssProjGUID, strSysCode))
            Else
                Dim dtTemp As DataTable = MyDB.GetDataTable(String.Format(" SELECT ProjGUID,ProjCode,ProjName FROM p_project WHERE MainProjGUID = '{0}' and  ApplySys LIKE '%{1}%' ", strDssProjGUID, strSysCode))
                If dtTemp.Rows.Count > 0 Then
                    Dim dtRow As DataRow = dtTemp.Rows(0)
                    Return String.Format("{0}|{1}|{2}", dtRow.Item("ProjGUID"), dtRow.Item("ProjCode"), dtRow.Item("ProjName"))
                End If
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function



    '功能：四舍五入（支持小数点后10位）
    Public Shared Function Round(ByVal dec As Decimal, ByVal decimals As Integer) As Decimal
        Dim DecReturn As Decimal

        Select Case decimals
            Case 0
                DecReturn = Int(dec + 0.5)
            Case 1
                DecReturn = Int(dec * 10 + 0.5) / 10
            Case 2
                DecReturn = Int(dec * 100 + 0.5) / 100
            Case 3
                DecReturn = Int(dec * 1000 + 0.5) / 1000
            Case 4
                DecReturn = Int(dec * 10000 + 0.5) / 10000
            Case 5
                DecReturn = Int(dec * 100000 + 0.5) / 100000
            Case 6
                DecReturn = Int(dec * 1000000 + 0.5) / 1000000
            Case 7
                DecReturn = Int(dec * 10000000 + 0.5) / 10000000
            Case 8
                DecReturn = Int(dec * 100000000 + 0.5) / 100000000
            Case 9
                DecReturn = Int(dec * 1000000000 + 0.5) / 1000000000
            Case 10
                DecReturn = Int(dec * 10000000000 + 0.5) / 10000000000
        End Select

        Return DecReturn
    End Function
End Class
